/*
 * Commment.cpp
 *
 *  Created on: Apr 13, 2011
 *      Author: nathanielclinger
 */

#include <iostream>
#include <string>
#include <sstream>
#include "Comment.hpp"

using namespace std;


Comment::Comment() {
	comment = "" ;
}

Comment::Comment( string s ) {
	comment = s ;
}

string Comment::getComment() {
	return comment ;
}

void Comment::addComment( string temp ) {
	comment = temp ;
}

char * getWebsiteName2()
{
	char * s = new char[10] ;
	strcpy( s, "Website name" ) ;
	return s ;
}

char * getStars2()
{
	char * str = new char[400] ;
	int plus = 10 ;
	int minus = 5 ;
	double p = plus/(plus+minus) ;
	p *= 5 ;
	strcpy( str, " " ) ;
	for( int i = 0 ; i < 5 ; i++ )
	{
		if( i < p )
			strcat( str, "<a href=\".\"><img class=\"star\" src=\"./images/star.png\" /></a>" ) ;
		else
			strcat( str, "<a href=\".\"><img class=\"star\" src=\"./images/starempty.png\" /></a>" ) ;
	}

	return str ;
}

char * getDate2()
{
	char * s = new char[10] ;
	strcpy( s, "26 April 2011" ) ;
	return s ;
}

char * getCategory2()
{
	char * s = new char[10] ;
	strcpy( s, "Category" ) ;
	return s ;
}

char * getFirstComment2()
{
	char * s = new char[10] ;
	strcpy( s, "some comment about stuff............." ) ;
	return s ;
}

char * getURL2()
{
	char * s = new char[100] ;
	strcpy( s, "http://communityseo.com/wp-content/uploads/2010/12/website-design.jpg" ) ;
	return s ;
}

char * getWebsitePic2()
{
	char * s = new char[10] ;
	strcpy( s, "./images/screen01.png" ) ;
	return s ;
}

int getUniqueVisits2()
{
	return 535 ;
}


int getPositiveVotes2()
{
	return 10 ;
}

int getNegativeVotes2()
{
	return 5 ;
}

int getTotalVotes2()
{
	int p = getPositiveVotes2() ;
	int n = getNegativeVotes2() ;
	int t = p + n ;
	return t ;
}


ostream& operator<<( ostream& os, const Comment& other )
{
	os << "<div class=\"contentbox\"><table class=\"contenttablehead\"><tr><td class=\"contentleft\">"
			<< "<h2><a href=\"websitename01\">" << getWebsiteName2() << "</a></h2></td><td class=\"contentright\">" ;

	os << getStars2() ;

	os << "</td></tr><tr><td class=\"tdauthor\">"
		<< "<p>Added on 26 April 2011 in <a href=\"\" class=\"category\">" << getCategory2() << "</a></p>"
		<< "</td><td class=\"tdratings\"><p>Total of " << getTotalVotes2() << " Votes</p></td></tr></table>" ;


	os << "<table class=\"contenttable\"><tr><td class=\"contentleft\">"
			<< "<p><a href=\"" << getURL2() << "\">" << getURL2() << "</a></p><hr />" ;

	os << "<h3>Latest Comments <a href=\"/" << getWebsiteName2() << "\" class=\"replies\">(Post a new comment)</a></h3>" ;

	// TODO: Loop through all the comments and add them one at a time
	os << "<p class=\"postdate\">Posted on " << getDate2() << "</p>"
				<< "<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>"
			<< "<a href=\"./" << getWebsiteName2() << "\" class=\"replies\">Reply to this comment</a>" ;

	return os ;
}
